//
//  Jsonstrin.m
//  DTSTON
//
//  Created by 喻贵华 on 16/5/23.
//  Copyright © 2016年 Demo. All rights reserved.
//

#import "Jsonstrin.h"

@implementation Jsonstrin
-(NSString *)JSONString{
    NSError *error = nil;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self
                                                       options:NSJSONWritingPrettyPrinted
                                                         error:&error];
    if (jsonData == nil) {
#ifdef DEBUG
        NSLog(@"fail to get JSON from dictionary: %@, error: %@", self, error);
#endif
        return nil;
    }
    NSString *jsonString = [[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\n   "]];
    return jsonString;
}
@end
